/**
 * Created by 陈奇 on 2015/1/13.
 */
var express = require('express'),
    router = express(),
    db = require('./../routes/conn'); //先引入数据库链接

router.get('/', function(req, resLogin) {
    var userlogin = req.param('userlogin'),
        passlogin = req.param('passlogin');
    db.pool.getConnection(function(err, connection) {
        var sql = 'select * from userinfo where UserName=? and UserPass=?',
            sql_val = [userlogin, passlogin];
        connection.query(sql, sql_val, function(error, res) {
            if (res.length != 0) {
                resLogin.redirect("index");
            } else {
                resLogin.render('login', {
                    title: "登陆页面"
                });
            }
        });

        connection.release();
    });
});

module.exports = router;